package core.report.yearReport.bean;

import core.report.yearReport.util.ExportExcelUtil;



public class ComparedCustomSalesReportDataBean extends ComparedSalesReportDataBean{
	
	private CustomSalesReportDataBean lastData;
	private CustomSalesReportDataBean data;
	
	@Override
	public void setLastReportDataBean(SalesReportDataBean lastDataBean) {
		CustomSalesReportDataBean lastData = (CustomSalesReportDataBean)lastDataBean;
		this.setLastData(lastData);
	}

	
	@Override
	public void setReportDataBean(SalesReportDataBean dataBean) {
		CustomSalesReportDataBean data = (CustomSalesReportDataBean)dataBean;
		this.setData(data);
	}
	
	public int getFormatTypeByIndex(int index){
		switch (index) {
		case 0:
			return ExportExcelUtil.TEXT_TYPE;
		case 1:
			return ExportExcelUtil.LONG_TYPE;
		case 2:
			return ExportExcelUtil.LONG_TYPE;
		case 3:
			return ExportExcelUtil.PERCENT_TYPE;
		case 4:
			return ExportExcelUtil.LONG_TYPE;
		case 5:
			return ExportExcelUtil.LONG_TYPE;
		case 6:
			return ExportExcelUtil.PERCENT_TYPE;
		case 7:
			return ExportExcelUtil.LONG_TYPE;
		case 8:
			return ExportExcelUtil.LONG_TYPE;
		case 9:
			return ExportExcelUtil.PERCENT_TYPE;
		case 10:
			return ExportExcelUtil.DECIMAL_TYPE;
		case 11:
			return ExportExcelUtil.DECIMAL_TYPE;
		case 12:
			return ExportExcelUtil.PERCENT_TYPE;
		case 13:
			return ExportExcelUtil.PERCENT_TYPE;
		case 14:
			return ExportExcelUtil.PERCENT_TYPE;
		case 15:
			return ExportExcelUtil.PERCENT_TYPE;
		case 16:
			return ExportExcelUtil.DECIMAL_TYPE;
		case 17:
			return ExportExcelUtil.DECIMAL_TYPE;
		case 18:
			return ExportExcelUtil.PERCENT_TYPE;
		case 19:
			return ExportExcelUtil.DECIMAL_TYPE;
		case 20:
			return ExportExcelUtil.DECIMAL_TYPE;
		case 21:
			return ExportExcelUtil.PERCENT_TYPE;
		default:
			return ExportExcelUtil.TEXT_TYPE;
		}
}

	public String getValueByIndex(int index) {
		String value = "";
		switch (index) {
		case 0:
			value = this.getData().getName()!=null?this.getData().getName():this.getLastData().getName();
			break;
		case 1:
			value = this.getLastData().getTotalAmount() + "";
			break;
		case 2:
			value = this.getData().getTotalAmount() + "";
			break;
		case 3:
//			if(this.getLastData().getTotalAmount()!=0){
//				value = (this.getData().getTotalAmount()-this.getLastData().getTotalAmount())/this.getLastData().getTotalAmount() + "";
//			}else{
//				value = "0";
//			}
			value = this.getGrouthRate_totalAmount()+"";
			break;
		case 4:
			value = this.getLastData().getCost_Amount() + "";
			break;
		case 5:
			value = this.getData().getCost_Amount() + "";
			break;
		case 6:
			if(this.getData().getCost_Amount()!=0){
				value = (this.getData().getCost_Amount()-this.getLastData().getCost_Amount())/this.getLastData().getCost_Amount() + "";
			}else{
				value = "0";
			}
			value = this.getGrouthRate_cost_Amount()+"";
			break;
		case 7:
			value = this.getLastData().getViews() + "";
			break;
		case 8:
			value = this.getData().getViews() + "";
			break;
		case 9:
//			if(this.getData().getViews()!=0){
//				value = ((double)this.getData().getViews()-(double)this.getLastData().getViews())/this.getLastData().getViews() + "";
//			}else{
//				value = "0";
//			}
			value = this.getGrouthRate_views()+"";
			break;
		case 10:
			value = this.getLastData().getGuests() + "";
			break;
		case 11:
			value = this.getData().getGuests() + "";
			break;
		case 12:
//			if(this.getData().getGuests()!=0){
//				value = (this.getData().getGuests()-this.getLastData().getGuests())/this.getLastData().getGuests() + "";
//			}else{
//				value = "0";
//			}
			value = this.getGrouthRate_guests()+"";
			break;
		case 13:
			value = this.getLastData().getSuccess_rate() + "";
			break;
		case 14:
			value = this.getData().getSuccess_rate() + "";
			break;
		case 15:
//			if(this.getData().getSuccess_rate()!=0){
//				value = (this.getData().getSuccess_rate()-this.getLastData().getSuccess_rate())/this.getLastData().getSuccess_rate() + "";
//			}else{
//				value = "0";
//			}
			value = this.getGrouthRate_success_rate()+"";
			break;
		case 16:
			value = this.getLastData().getPiecesPrice() + "";
			break;
		case 17:
			value = this.getData().getPiecesPrice() + "";
			break;
		case 18:
//			if(this.getData().getPiecesPrice()!=0){
//				value = (this.getData().getPiecesPrice()-this.getLastData().getPiecesPrice())/this.getLastData().getPiecesPrice() + "";
//			}else{
//				value = "0";
//			}
			value = this.getGrouthRate_piecesPrice()+"";
			break;
		case 19:
			value = this.getLastData().getPieces_per_price() + "";
			break;
		case 20:
			value = this.getData().getPieces_per_price() + "";
			break;
		case 21:
//			if(this.getData().getPieces_per_price()!=0){
//				value = (this.getData().getPieces_per_price()-this.getLastData().getPieces_per_price())/this.getLastData().getPieces_per_price() + "";
//			}else{
//				value = "0";
//			}
			value = this.getGrouthRate_pieces_per_price()+"";
			break;
		}
		return value;
	}


	public CustomSalesReportDataBean getLastData() {
		return lastData;
	}


	public void setLastData(CustomSalesReportDataBean lastData) {
		this.lastData = lastData;
	}


	public CustomSalesReportDataBean getData() {
		return data;
	}


	public void setData(CustomSalesReportDataBean data) {
		this.data = data;
	}


	@Override
	public SalesReportDataBean getLastReportDataBean() {
		return getLastData();
	}


	@Override
	public SalesReportDataBean getReportDataBean() {
		return getData();
	}


	@Override
	public int compareTo(ComparedSalesReportDataBean obj) {
		SalesReportDataBean bean = null;
		if(this.getReportDataBean().getName()!=null){
			bean = getReportDataBean();
		}else{
			bean = getLastReportDataBean();
		}
		
		SalesReportDataBean otherBean = null;
		if(obj.getReportDataBean().getName()!=null){
			otherBean = obj.getReportDataBean();
		}else{
			otherBean = obj.getLastReportDataBean();
		}
		if(bean!=null&&otherBean!=null){
			int compare = bean.compareTo(otherBean);
			return compare;
		}
		return 0;
	}
}
